﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Loong.Admin.Roles
{
    public class RoleClaimConfiguration : IEntityTypeConfiguration<RoleClaim>
    {
        public void Configure(EntityTypeBuilder<RoleClaim> b)
        {
            b.ToTable("RoleClaims");

            b.ConfigureByConvention();

            b.Property(x => x.Id).ValueGeneratedNever();

            b.Property(uc => uc.ClaimType)
                .HasMaxLength(RoleClaimConsts.MaxClaimTypeLength)
                .IsRequired();

            b.Property(uc => uc.ClaimValue)
                .HasMaxLength(RoleClaimConsts.MaxClaimValueLength);

            b.HasIndex(uc => uc.RoleId);
        }
    }
}
